package com.cainiao.mapper;

import com.cainiao.pojo.Emp;
import com.cainiao.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


@Mapper
public interface EmpMapper {

    List<Emp> page(EmpQueryParam empQueryParam);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) " +
            "values(#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void add(Emp emp);

    @Select("select * from emp")
    List<Emp> findEmps();

    void deleteByIds(List<Integer> ids);

    Emp findById(Integer id);

    void update(Emp emp);

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp findByUsernameAndPassword(Emp emp);

    @Select("select count(*) from emp where dept_id=#{deptId}")
    Integer countByDeptId(Integer deptId);

    @MapKey("jobList")
    List<Map<String,Object>> empJobData();

    List<Map<String,Object>> empGenderData();
}
